import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './Router';
import { BrowserRouter as Router } from 'react-router-dom';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { ConfigProvider, App as _App } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import './config/globalStyle.less';
import 'antd/dist/reset.css';

dayjs.locale('zh-cn');

const dom = document.getElementById('root');

console.log(process.env.NODE_ENV === 'development' ? '/' : '/admin');
console.log(process.env.NODE_ENV, process.env);

if (dom) {
  const root = createRoot(dom);
  root.render(
    <ConfigProvider
      locale={zhCN}
      theme={{
        token: {
          colorPrimary: '#056de8',
          borderRadius: 0,
        },
      }}
      prefixCls="un"
    >
      {/* process.env.NODE_ENV === 'development' ? '/' : '/admin' */}
      <Router basename={process.env.NODE_ENV === 'development' ? '/' : '/admin'}>
        <_App style={{ height: '100%' }}>
          <App />
        </_App>
      </Router>
    </ConfigProvider>
  );
}
